<template>
  <div class="goods">
    <!-- 搜索区 -->
    <page-search :searchFormConfig="searchFormConfig" @newSearchEvent="handlerSearch"></page-search>
    <!-- 商品展示区 -->
    <page-table
      ref="pageTableRef"
      :pageTabelConfig="pageTabelConfig"
      page-name="Goods"
      @pageTableEvent="handlerDialog"
      @showEmptyDialog="handlerDialog"
    >
      <template #imgUrl="scope">
        <el-image
          style="width: 40px; height: 50px"
          :src="scope.row.imgUrl"
          :preview-src-list="[scope.row.imgUrl]"
          :initial-index="0"
        >
        </el-image>
      </template>
      <template #oldPrice="scope">
        <el-column>￥{{ scope.row.oldPrice }}</el-column>
      </template>
    </page-table>

    <!-- dialog对话框 -->
    <page-dialog page-name="Goods" ref="pageDialogRef" :editDialogFormConfig="editDialogFormConfig"></page-dialog>
  </div>
</template>

<script lang="ts">
import { defineComponent } from "vue"
import PageTable from "@/components/page-table"
import { pageTabelConfig } from "@/views/main/system/goods/config/goods.config"

import PageSearch from "@/components/page-search"

import { searchFormConfig } from "@/views/main/system/goods/config/search.config"
import { handlerSearch, pageTableRef } from "@/hook/usePageSearch"

import PageDialog from "@/components/page-dialog"
import { editDialogFormConfig } from "@/views/main/system/goods/config/editDialog.config"
import { pageDialogRef, handlerDialog } from "@/hook/usePageDialog"
export default defineComponent({
  name: "goods",
  components: {
    PageTable,
    PageSearch,
    PageDialog,
  },
  setup() {
    return {
      pageTabelConfig,
      searchFormConfig,
      handlerSearch,
      pageTableRef,
      editDialogFormConfig,
      pageDialogRef,
      handlerDialog,
    }
  },
})
</script>

<style scoped></style>
